function showMenu(){
		hui('.hui-slide-menu').css({display: 'block',top: '20px'});
		hui('#mask').css({display: 'block'});
	}
	function hideMenu(){
		hui('.hui-slide-menu').css({display: 'none'});
		hui('#mask').css({display: 'none'});
	}
	
	
	hui.ready(function() {
		//轮播图控制
		var swipe = new huiSwpie('#swipe');
		swipe.autoPlay = true;
		swipe.run();
		
		//默认第一次调用基地数据请求 
		getColumns();
	})
	var datas = new Vue({
		el: '#datas',
		data: {
			userInfo: getUserInfo(),
			columns: [],
			list: [],

			selectListIndex: 0,
		},
		methods: {
			//选中左侧基地
			onColumnSelected: function(column, index) {
				this.selectListIndex = index;
				getSensorList(column);
			},
			//左侧基地选中class
			getLeftClass: function(index,columnId,columnName) {
				if(this.selectListIndex == index) {
					console.log("左边列表选中666:" + index);
					Sensor_Base = columnId;
					Sensor_Name = columnName;
					console.log("左边列表选中Id:" + Sensor_Base);
					console.log("左边列表选中的基地名字是:" + Sensor_Name);
					hideMenu();
					hui('.base_name').html(Sensor_Name)
				}
				return index == this.selectListIndex ? "column_div selected" : "column_div";
			},
			//过滤掉不要显示 display不为1的基地
			getFilterColumn: function() {
				return this.columns.filter(function(column) {
					let fistC = column.display == 1;
					return fistC;
				});

			},
			onDetailSelected: function(detail) {
				var url = "detail_R.html?sid=" + detail.Id;
				url += "&tid=" + detail.TargetId;
				url += "&data=" + getFloat(format(detail.MeasureData, '0'), 3);
				url += "&name=" + detail.TargetName;
				url += "&unit=" + detail.TargetUnit;
				url += "&base=" + Sensor_Base;
				url += "&sensorN=" + Sensor_Name;
				console.log(url);
				hui.open(encodeURI(url), {}, true, {});
			},
			// 获取头像
			getHead: function() {
				console.log('header:' + JSON.stringify(this.userInfo)); 
				let avatar = ""
				if(this.userInfo && this.userInfo.avatar) {
					avatar = baseURL() + this.userInfo.avatar;
				} else {
					avatar = "img/head_icon.png";
				}
				return avatar;
			},
			//获得右侧指标图标
			getIcon: function(column) {
				var type = column.TargetName;
				var icon = getIconByTarget(type);

				return icon;
			},
			getValue: function(detail) {
				var tmp = format(detail.MeasureData, '0');
				var type = detail.TargetName;
				return getFloat(tmp, 3) + detail.TargetUnit;
			}
		}
	})
	function openSetting(){
		hui.open("account.html", {}, true, {});
	}
	
	
	
	//基地数据请求
	function getColumns() {
		var userId = getUserId();
		var url = baseURL() + "/interfaces/gateway_handler.ashx?action=gateway_user";
		var param = {
			uid: userId
		};

		postJson(url, param, function(ret) {
			printLog(ret, "栏目");
			datas.columns = ret.data;

			localStorage.setItem("columns", JSON.stringify(datas.columns));
			
			if(ret.data.length > 0) {
				var showFirst = false;
				for(var i = 0; i < ret.data.length; i++) {
					var d = ret.data[i];
					if(d.display == 1 && !showFirst) {
						showFirst = true;
						getSensorList(d);
					}
				}

				setTimeout(function() {
					datas.selectListIndex = 0;
				}, 500)
			}
		});
	}
	
	//指标数据请求
	function getSensorList(column) {

		var columnId = column.Id;
		var url = baseURL() + "/interfaces/gateway_handler.ashx?action=gateway_target";
		var param = {
			gid: columnId
		};

		datas.list = [];
		hui("#load").show(true);
		printLog(param);
		postJson(url, param, function(ret) {
			printLog(ret, "传感器");
		
			hui("#load").hide(true);

			setTimeout(function() {
				datas.list = ret.data;
			}, 500);
		}, function(e) {
			hui("#load").hide(true);
		});
	}